package main;

import org.jboss.aop.joinpoint.MethodInvocation;
import org.jboss.aop.joinpoint.ConstructorInvocation;
import org.jboss.aop.joinpoint.FieldWriteInvocation;

public class LoggingAspect {

	public Object log(FieldWriteInvocation invocation) throws Throwable {
		try {
			System.out.println("F: " + invocation.getField() + " = " + invocation.getValue());
			return invocation.invokeNext();
		} finally {
			
		}
	
	}
	
	public Object log(ConstructorInvocation invocation) throws Throwable {
	//public Object log(ConstructionInvocation invocation) throws Throwable {
		try {
			System.out.println("C: " + invocation.getConstructor() + " ( " + invocation.getArguments()[0] + ",  " + invocation.getArguments()[1] +")");
			return invocation.invokeNext();
		} finally {
			
		}
	
	}
	
	public Object log(MethodInvocation invocation) throws Throwable {
	//public Object log(ConstructionInvocation invocation) throws Throwable {
		try {
			System.out.println("M: " + invocation.getMethod());
			return invocation.invokeNext();
		} finally {
			
		}
	
	}

}
